package br.com.sistemavendas.dao;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
	
	private static final SessionFactory session = buildSessionFactory1();


	private static SessionFactory buildSessionFactory1() {
		AnnotationConfiguration cfg = null;
		try {
			cfg = new AnnotationConfiguration();
			cfg.configure("hibernate.cfg.xml");
			System.out.println("conectou!");

		} catch(Throwable e) {
			System.out.println("deu problema " + e);
			throw new ExceptionInInitializerError();
		}
		
		return cfg.buildSessionFactory();
		
	}
	
	public static SessionFactory getSession() {
		return session;
	}
	
}
